package awesome.security;

import java.security.DigestException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Digest {
	public static String digest(String message)
	{
	MessageDigest md;
	byte[] toChapter1Digest= null;
	
	try {
		md = MessageDigest.getInstance("MD5");
		
		byte[] toChapter1 = message.getBytes();
		
		
		md.update(toChapter1);
     	MessageDigest tc1 = (MessageDigest) md.clone();
		toChapter1Digest = tc1.digest();
		     
		 
	} catch (NoSuchAlgorithmException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	catch (CloneNotSupportedException cnse) {
	     System.out.println("couldn't make digest of partial content");
	 }
	
	 return new String(toChapter1Digest);
	}
}


